<script type="text/javascript" src="<?=base_url()?>js/popup.js"></script>
<link href="<?=base_url()?>css/popup.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
$j(document).ready(function(){
				
	//CLOSING POPUP	
	//Click out event!
	$j("#background-popup").click(function(){
		disablePopup();
	});
	//Press Escape event!
	$j(document).keypress(function(e){
		if(e.keyCode==27 && popupStatus==1){
			disablePopup();
		}
	});

}); 
/*
function addtocart(id) 
{
	$j.ajax({
		url: '<?=base_url()?>store/addtocart/',
		type: 'POST',
		data: "product_id=" + id,
		dataType: "html",
		success: function(html) {
			updatecart();
			updatenumberitems();
			$j('#content-pop').html(html);
			centerPopup();
	loadPopup();
		}
	})
}
*/
function subscribe() {
	var valid = true;
	var email = $j('#email2').val();
	if(email == "") 
	{ 
	   $j('#email2').css('background','#fff3a0'); valid = false; 
	}
	else 
	{ 
	   if(!echeck(email))
		{
			$j('#email2').css('background','#fff3a0'); 
	        valid = false;
		}
		else
		{
			$j('#email2').css('background','#fff');
		}
	   
	}
	if (valid) 
	{
		$j.ajax({
		url: '<?=base_url()?>ajax_subscribe/',
		type: 'POST',
		data: {email2:email},
		dataType: "html",
		success: function(html) {
			alert(html);
			$j('#email2').val('');
		}
	})
	}
}
function echeck(str) {

                var at = "@"
                var dot = "."
                var lat = str.indexOf(at)
                var lstr = str.length
                var ldot = str.indexOf(dot)
                if (str.indexOf(at) == -1) {
                    alert("Please Enter A Valid E-mail")
                    return false
                }

                if (str.indexOf(at) == -1 || str.indexOf(at) == 0 || str.indexOf(at) == lstr) {
                    alert("Please Enter A Valid E-mail")
                    return false
                }

                if (str.indexOf(dot) == -1 || str.indexOf(dot) == 0 || str.indexOf(dot) == lstr) {
                    alert("Please Enter A Valid E-mail")
                    return false
                }

                if (str.indexOf(at, (lat + 1)) != -1) {
                    alert("Please Enter A Valid E-mail")
                    return false
                }

                if (str.substring(lat - 1, lat) == dot || str.substring(lat + 1, lat + 2) == dot) {
                    alert("Please Enter A Valid E-mail")
                    return false
                }

                if (str.indexOf(dot, (lat + 2)) == -1) {
                    alert("Please Enter A Valid E-mail")
                    return false
                }

                if (str.indexOf(" ") != -1) {
                    alert("Please Enter A Valid E-mail")
                    return false
                }


                return true;
            }
</script>
<div id="popup-box">
	
    <div id="popup-shopping">
    	<div class="close"><a href="javascript:disablePopup()"><img src="<?=base_url()?>img/CloseButton-Up.png" alt="Close" /></a></div>
        <div style="clear:both"></div>
        <div style="clear:both;padding-top:54px">
           <div id="content-pop" style="width:400px;margin:0 auto"></div>
        </div>
        <br/>
    </div>
</div>
<div id="background-popup"></div>
<div id="home_top_container"><!--<img src="<?=base_url()?>img/temp-banner.png" alt="" />-->
	<img src="<?=base_url()?>uploads/banners/newbanner.jpg" alt="" />
	<!--
   <div id="splash"><a href="<?=base_url()?>store/redirect/<?=$banner['id']?>" class="splash"><img src="<?=base_url()?>uploads/banners/Unknown-1.jpeg" alt="" /></a></div>
   <!--
   <div id="home_top_right">
     <div><a href="<?=base_url()?>store/trade"><img src="<?=base_url()?>img/signup-banner.png" alt="" /></a></div>
      <div style="margin-top:2px;width:219px;height:142px;background:url(<?=base_url()?>img/merchandise-news.png)">
        <div style="padding-top:90px;margin-left:12px;width:198px">
         <table cellpadding="0" cellspacing="0" border="0">
                   <tr><td><input type="text" name="email2" id="email2" style="width:128px" /></td><td><a href="#" onclick="subscribe()"><img src="<?=base_url()?>img/signup-button.jpg" alt="Sign Up" /></a></td>
                   </tr>
         </table>
        </div>
     </div>
   </div>
   -->
</div>
<div style="margin-top:2px;clear:both">
   <div><img src="<?=base_url()?>img/home-on-sale-header.png" alt="Current On Sale Items | Current On Sale Bundle Packs" /></div>
   <div id="feature_products">
     <table cellpadding="0" cellspacing="0" border="0" width="892">
      <tr>
          <?php foreach($products as $product) { 
				$photo = $this->Product_model->thumb_photo($product['id']); ?>
            <td width="223">
              <div class="product-thumb">
            	<?php if($photo) { ?>
            	<a href="<?=base_url()?>store/product/<?=$product['id']?>"><img src="<?=base_url()?>uploads/products/<?=md5('mbb'.$product['id'])?>/thumb2/<?=$photo['name']?>" alt="" /></a>
                <?php } else { ?>
                <a href="<?=base_url()?>store/product/<?=$product['id']?>"><img src="<?=base_url()?>img/nophoto.jpg" alt="No Image" /></a>
                <?php } ?>
                <div class="product-box">
                 <p class="p-name"><?=$product['title']?></p>
                 <p class="p-price">
                	<?php 
                	if($product['sale_price'] < $product['price']) { 
						$price = money_format('%i',$product['price']);
						$sale_price = money_format('%i',$product['sale_price']); ?>
                	<span class="old">$<?=$price?></span> $<?=$sale_price?>
                    <?php } else { 
						$price = money_format('%i',$product['price']); ?>
                    <span class="normal">$<?=$price?></span>
                    <?php } ?>
                 </p>
                 <div style="margin:auto;margin-top:2px;width:88px;">
                   <table cellpadding="0" cellspacing="0" border="0" align="center">
                     <tr>
                       <td align="center"><a href="<?=base_url()?>store/product/<?=$product['id']?>"><img src="<?=base_url()?>img/view-product-button.png" alt="View Product" /></a></td>
                       <!--<td width="29">&nbsp;</td>
                       <td><a href="javascript:addtocart(<?=$product['id']?>)"><img src="<?=base_url()?>img/add-to-basket-button.png" alt="Add To Basket" /></a></td>-->
                     </tr>
                   </table>
                 </div>
                </div>
              </div>
            </td>
            <?php } ?>
      </tr>
      
     </table>
       <!--
            <?php foreach($products as $product) { 
				$photo = $this->Product_model->thumb_photo($product['id']); ?>
            <div class="product-thumb">
            	<?php if($photo) { ?>
            	<a href="<?=base_url()?>store/product/<?=$product['id']?>"><img src="<?=base_url()?>uploads/products/<?=md5('mbb'.$product['id'])?>/thumb2/<?=$photo['name']?>" /></a>
                <?php } else { ?>
                <a href="<?=base_url()?>store/product/<?=$product['id']?>"><img src="<?=base_url()?>img/nophoto.jpg" /></a>
                <?php } ?>
                <p class="p-name"><?=$product['title']?></p>
                <p class="p-desc"><?=$product['short_desc']?></p>
                <p class="p-price">
                	<?php 
                	if($product['sale_price'] < $product['price']) { 
						$price = money_format('%i',$product['price']);
						$sale_price = money_format('%i',$product['sale_price']); ?>
                	<span class="old">$<?=$price?></span> $<?=$sale_price?>
                    <?php } else { 
						$price = money_format('%i',$product['price']); ?>
                    <span class="normal">$<?=$price?></span>
                    <?php } ?>
                </p>
            </div>
            <?php } ?>
            -->
   </div>
</div>